package com.wanmait.movie.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.wanmait.movie.entity.MovieTypes;
import com.wanmait.movie.mapper.MovieTypesMapper;
import com.wanmait.movie.service.MovieTypesService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;

@Service
@Transactional(rollbackFor = Exception.class)
public class MovieTypesServiceImpl extends ServiceImpl<MovieTypesMapper , MovieTypes> implements MovieTypesService {
    @Resource
    private MovieTypesMapper movieTypesMapper;

    @Override
    public List<Integer> getMovieTypeListByMovieId(Integer id) {
        LambdaQueryWrapper<MovieTypes> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(MovieTypes::getMovieId, id);
        List<Integer> list = new ArrayList<>();
        movieTypesMapper.selectList(queryWrapper).forEach(movieType -> {
            list.add(movieType.getMovieTypeId());
        });
        return list;
    }
}
